

#include <iostream>
#include <map>
#include <cctype>
#include <queue>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

class Solution
{
public:
    vector<vector<int>> generate(int Rows)
    {
        vector<vector<int>> vv(Rows);

        for (int i = 0; i < Rows; ++i)
        {
            vv[i].resize(i + 1, 1);

            for (int j = 1; j < vv[i].size() - 1; ++j)
            {
                vv[i][j] = vv[i - 1][j] + vv[i - 1][j - 1];
            }
        }

        return vv;
    }

    vector<string> permutation(string S)
    {
        vector<string> vs;
        vector<bool> visited(S.size(), false);

        _per(S, visited, string(), vs);

        return vs;
    }

private:
    void _per(const string& s, vector<bool>& vtd, string str, vector<string>& vs)
    {
        if (str.size() == s.size())
        {
            vs.push_back(str);
            return;
        }

        for (int i = 0; i < s.size(); ++i)
        {
            if (vtd[i])
                continue;
            str += s[i];
            vtd[i] = true;
            _per(s, vtd, str, vs);
            str.pop_back();
            vtd[i] = false;
        }
    }
};

void Test1()
{
    string s = "-1";
    int a = stoi(s);
    long l = stol(s);
    unsigned int ui = stoul(s);
    UINT_MAX;
    /*while (cin >> s)
    {
        cout << s << endl;
    }*/

    cout << a << endl;
    cout << l << endl;
    cout << ui << endl;
}

struct kvComp
{
    bool operator()(const pair<string, int>& x, const pair<string, int>& y)
    {
        return x.second < y.second || (x.second == y.second && x.first > y.first);
    }
};

void Test2()
{
    string s;
    map<string, int> cnt;

    string s;
    map<string, int> cnt;

    while (cin >> s)
    {
        if (s.back() == '.')
            s.pop_back();
        transform(s.begin(), s.end(), s.begin(), ::tolower);
        ++cnt[s];
    }

    priority_queue<pair<string, int>, vector<pair<string, int>>, kvComp> hp(cnt.begin(), cnt.end());

    while (!hp.empty())
    {
        cout << hp.top().first << ":" << hp.top().second << endl;
        hp.pop();
    }


    priority_queue<pair<string, int>, vector<pair<string, int>>, kvComp> hp(cnt.begin(), cnt.end());

    while (!hp.empty())
    {
        cout << hp.top().first << ":" << hp.top().second << endl;
        hp.pop();
    }
}

int main()
{
    //Test1();
    Test2();


	return 0;
}